package com.chinasoft.mapper;

import com.chinasoft.pojo.User;
import com.chinasoft.pojo.Userlist;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {
    @Select("select * from user")
    List<User> findAll();

    @Select("select * from user where username=#{username}")
    User selectByName(String username);

    @Select("select * from user where usertype=#{usertype}")
    List<User> selectByType(String usertype);

    @Update("UPDATE user SET type = #{type} , endtime = #{endtime} WHERE username = #{username}")
    int updateDel(@Param("username") String username, @Param("type")String type, @Param("endtime")String endtime);

    @Delete("DELETE FROM user WHERE username = #{username}")
    int delete(String username);

    @Insert("INSERT INTO user (username,name,gender, password,usertype,intime) " +
            " VALUES (#{username},#{name},#{gender}, #{password}, #{usertype}, #{intime})")
    int insert(User user);

    @Insert("INSERT INTO user (username,name,gender,password,usertype) " +
            " VALUES (#{username},#{name},#{gender}, #{password}, #{usertype})")
    int insertUser(User user);

    @Update("UPDATE user SET intime =#{intime} WHERE username = #{username}")
    int update(@Param("username") String username, @Param("intime")String intime);

    @Update("UPDATE user SET password =#{password} WHERE username = #{username}")
    int setPassword(@Param("username") String username, @Param("password")String password);
}